import axios from "../utils/axios"

// 获取文章信息
function getArticles(){
    return axios.get("/articles")
}

// 获取文章类别名称
function getArticleCategory(){
    return axios.get("/articles/ArticleCategory")
}

// 添加文章
function postArticle(data){
    return axios.post("/articles/addAritcle",data)
}

// 上传图片
function postUpload(file){
    return axios.post("/articles/UploadImage",file)
}

// 修改文章信息
function putArticle(id,data){
    return axios.put(`/articles/putArticle/${id}`,data)
}

// 删除文章
function deleteArticle(id){
    return axios.delete(`/articles/deleteArticle/${id}`)
}

// 根据文章Id添加文章图片
function InsterArticlePictureById(id,data){
    return axios.post(`/articles/InsterArticlePicture/${id}`,data)
}

function UploadImage(data){
    return axios({
        method:'post',
        url:'/File/UploadImage',
        data:data,
        headers:{'Content-Type': 'multipart/form-data'}
    })
}

export {
    getArticles,
    getArticleCategory,
    postArticle,
    postUpload,
    putArticle,
    deleteArticle,
    InsterArticlePictureById,
    UploadImage
}